<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: gengchao
  Date: 2021/7/15
  Time: 10:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<table>
    <tr>
        <td>id</td>
        <td>姓名</td>
        <td>装备</td>
        <td>价格</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${list}" var="item">
    <tr>
        <td>${item.id}</td>
        <td>${item.userName}</td>
        <td>${item.equipName}</td>
        <td>${item.price}</td>
        <td><button onclick="buy(${item.id})">购买</button></td>
    </tr>
    </c:forEach>
</table>
</body>
<script src="https://www.jq22.com/jquery/jquery-1.7.1.js"></script>
<script>
    function  buy(id) {
        $.ajax({
            //这个地址
            "url":"buy",
            //这种方式
            "type":"post",
            //传递这样的数据
            "data":{"id":id},
            "dataType":"json",
            "success":function (data){
                console.log(data);
            },
            "error":function (a,b,c) {
                console.log(a);
                console.log(b);
                console.log(c);
            }
        });
    }
</script>
</html>
